package com.example.lxq.demo.config;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class SpringObserver {
    public static ConfigurableApplicationContext context;

    public static SpringListener springListener;
    public static String vPath;

    public void registerListener() {
        context.addApplicationListener(new ApplicationListener<ApplicationFailedEvent>() {
            @Override
            public void onApplicationEvent(ApplicationFailedEvent arg0) {
                springListener.onFailed();
            }
        });
        context.addApplicationListener(new ApplicationListener<ApplicationReadyEvent>() {
            @Override
            public void onApplicationEvent(ApplicationReadyEvent arg0) {
                springListener.onReady();
                if(vPath==null){
                    vPath="D:\\model space/";
                }
            }
            
        });
    }
}
